# -*- coding: utf-8 -*-

################################################################################
## Form generated from reading UI file '获取doublespinbox中的小数数字.ui'
##
## Created by: Qt User Interface Compiler version 5.15.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
import sys
from PySide2 import QtWidgets


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        self.doubleSpinBox = QDoubleSpinBox(self.centralwidget)
        self.doubleSpinBox.setObjectName(u"doubleSpinBox")
        self.doubleSpinBox.setGeometry(QRect(270, 160, 201, 71))

        # 设置doublespinbox的相关属性（最小值、最大值、步长、保留位数）
        self.doubleSpinBox.setMinimum(0)
        self.doubleSpinBox.setMaximum(99.999)
        self.doubleSpinBox.setSingleStep(0.001)
        self.doubleSpinBox.setDecimals(3)

        # 设置doublespinbox的信号与槽
        self.doubleSpinBox.valueChanged.connect(self.getvalue)

        self.label = QLabel(self.centralwidget)
        self.label.setObjectName(u"label")
        self.label.setGeometry(QRect(270, 300, 200, 80))      # 注意：四个参数分别代表 x、y、长、高
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(MainWindow)
        self.menubar.setObjectName(u"menubar")
        self.menubar.setGeometry(QRect(0, 0, 800, 26))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName(u"statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)

        QMetaObject.connectSlotsByName(MainWindow)
    # setupUi

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"\u83b7\u53d6doublespinbox\u4e2d\u7684\u5c0f\u6570\u6570\u5b57", None))
        self.label.setText(QCoreApplication.translate("MainWindow", u"\u6570\u5b57\u663e\u793a\u533a\u57df", None))
    # retranslateUi
    def getvalue(self):
        self.label.setText(f"当前控件中显示的值为{str(self.doubleSpinBox.value())}")


if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())